﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Collections.ObjectModel;
using System.Windows.Controls;
using System.Windows;
using Microsoft.Win32;
using System.Threading;
using System.IO;
using BDSim.用户界面.SubWindows;
using System.Diagnostics;

namespace BDSim
{
    public partial class MainWindowViewModel
    {
        #region 定义SimpleCommand命令

        #region ///文件栏命令
        private SimpleCommand _CmdOpenFile = new SimpleCommand();
        private SimpleCommand _CmdExportSimData = new SimpleCommand();
        private SimpleCommand _CmdSaveFile = new SimpleCommand();
        private SimpleCommand _CmdCloseBDSim = new SimpleCommand();
        private SimpleCommand _CmdRunWizard = new SimpleCommand();
        private SimpleCommand _CmdPluginManage = new SimpleCommand();

        
        /// <summary>
        /// 打开仿真场景
        /// </summary>
        public SimpleCommand CmdOpenFile
        {
            get { return _CmdOpenFile; }
            set { _CmdOpenFile = value; }
        }

        /// <summary>
        /// 保存仿真场景
        /// </summary>
        public SimpleCommand CmdSaveFile
        {
            get { return _CmdSaveFile; }
            set { _CmdSaveFile = value; }
        }
        /// <summary>
        /// 插件管理
        /// </summary>
        public SimpleCommand CmdPluginManage
        {
            get { return _CmdPluginManage; }
            set { _CmdPluginManage = value; }
        }
        /// <summary>
        /// 退出BDSim软件平台
        /// </summary>
        public SimpleCommand CmdCloseBDSim
        {
            get { return _CmdCloseBDSim; }
            set { _CmdCloseBDSim = value; }
        }

        /// <summary>
        /// 开始向导
        /// </summary>
        public SimpleCommand CmdRunWizard
        {
            get { return _CmdRunWizard; }
            set { _CmdRunWizard = value; }
        }

        /// <summary>
        /// 导出仿真数据
        /// </summary>
        public SimpleCommand CmdExportSimData
        {
            get { return _CmdExportSimData; }
            set { _CmdExportSimData = value; }
        }

        #endregion

        #region ///数据处理工具栏命令
        private SimpleCommand _CmdTimeConvert = new SimpleCommand();
        private SimpleCommand _CmdCoordConvert = new SimpleCommand();
        private SimpleCommand _CmdNavMsgDecode = new SimpleCommand();
        private SimpleCommand _CmdROD = new SimpleCommand();
        private SimpleCommand _CmdRealDataHandle = new SimpleCommand();
        
        /// <summary>
        /// 时间转换
        /// </summary>
        public SimpleCommand CmdTimeConvert
        {
            get { return _CmdTimeConvert; }
            set { _CmdTimeConvert = value; }
        }

        /// <summary>
        /// 坐标转换
        /// </summary>
        public SimpleCommand CmdCoordConvert
        {
            get { return _CmdCoordConvert; }
            set { _CmdCoordConvert = value; }
        }

        /// <summary>
        /// 导航电文解析
        /// </summary>
        public SimpleCommand CmdNavMsgDecode
        {
            get { return _CmdNavMsgDecode; }
            set { _CmdNavMsgDecode = value; }
        }

        /// <summary>
        /// 主控站定轨
        /// </summary>
        public SimpleCommand CmdROD
        {
            get { return _CmdROD; }
            set { _CmdROD = value; }
        }

        /// <summary>
        /// 实测数据处理
        /// </summary>
        public SimpleCommand CmdRealDataHandle
        {
            get { return _CmdRealDataHandle; }
            set { _CmdRealDataHandle = value; }
        }
        #endregion

        #region ///视图栏命令
        private SimpleCommand _CmdScenarioConfig = new SimpleCommand();
        private SimpleCommand _CmdPropertyConfig = new SimpleCommand();
        private SimpleCommand _CmdSimMsgReport = new SimpleCommand();
        private SimpleCommand _CmdPPEvaluation = new SimpleCommand();
        private SimpleCommand _CmdThreeDimension = new SimpleCommand();
        private SimpleCommand _CmdEarthMap = new SimpleCommand();

        /// <summary>
        /// 仿真场景窗口显示/隐藏命令
        /// </summary>
        public SimpleCommand CmdScenarioConfig
        {
            get { return _CmdScenarioConfig; }
            set { _CmdScenarioConfig = value; }
        }
        
        /// <summary>
        /// 属性配置窗口显示/隐藏命令
        /// </summary>
        public SimpleCommand CmdPropertyConfig
        {
            get { return _CmdPropertyConfig; }
            set { _CmdPropertyConfig = value; }
        }
        
        /// <summary>
        /// 仿真消息报告窗口显示/隐藏命令
        /// </summary>
        public SimpleCommand CmdSimMsgReport
        {
            get { return _CmdSimMsgReport; }
            set { _CmdSimMsgReport = value; }
        }

        
        /// <summary>
        /// 定位评估窗口显示/隐藏命令
        /// </summary>
        public SimpleCommand CmdPPEvaluation
        {
            get { return _CmdPPEvaluation; }
            set { _CmdPPEvaluation = value; }
        }

        /// <summary>
        /// 三维可视化窗口显示/隐藏命令
        /// </summary>
        public SimpleCommand CmdThreeDimension
        {
            get { return _CmdThreeDimension; }
            set { _CmdThreeDimension = value; }
        }
        
        /// <summary>
        /// 二维地图窗口显示/隐藏命令
        /// </summary>
        public SimpleCommand CmdEarthMap
        {
            get { return _CmdEarthMap; }
            set { _CmdEarthMap = value; }
        }
        
        #endregion

        #region///设置栏命令
        SimpleCommand _CmdSystemSetting = new SimpleCommand();

        /// <summary>
        /// 系统设置
        /// </summary>
        public SimpleCommand CmdSystemSetting
        {
            get { return _CmdSystemSetting; }
            set { _CmdSystemSetting = value; }
        }

        #endregion

        #region ///仿真控制命令
        private SimpleCommand _CmdInit = new SimpleCommand();
        private SimpleCommand _CmdRun = new SimpleCommand();
        private SimpleCommand _CmdPause = new SimpleCommand();
        private SimpleCommand _CmdContinue = new SimpleCommand();
        private SimpleCommand _CmdEndRun = new SimpleCommand();
        private SimpleCommand _CmdRunSlower = new SimpleCommand();
        private SimpleCommand _CmdRunFaster = new SimpleCommand();

        /// <summary>
        /// 系统初始化
        /// </summary>
        public SimpleCommand CmdInit
        {
            get { return _CmdInit; }
            set { _CmdInit = value; }
        }

        /// <summary>
        /// 运行仿真
        /// </summary>
        public SimpleCommand CmdRun
        {
            get { return _CmdRun; }
            set { _CmdRun = value; }
        }

        /// <summary>
        /// 暂停仿真
        /// </summary>
        public SimpleCommand CmdPause
        {
            get { return _CmdPause; }
            set { _CmdPause = value; }
        }

        /// <summary>
        /// 继续仿真
        /// </summary>
        public SimpleCommand CmdContinue
        {
            get { return _CmdContinue; }
            set { _CmdContinue = value; }
        }

        /// <summary>
        /// 结束仿真
        /// </summary>
        public SimpleCommand CmdEndRun
        {
            get { return _CmdEndRun; }
            set { _CmdEndRun = value; }
        }

        /// <summary>
        /// 减慢一倍速度仿真
        /// </summary>
        public SimpleCommand CmdRunSlower
        {
            get { return _CmdRunSlower; }
            set { _CmdRunSlower = value; }
        }

        /// <summary>
        /// 增加一倍速度仿真
        /// </summary>
        public SimpleCommand CmdRunFaster
        {
            get { return _CmdRunFaster; }
            set { _CmdRunFaster = value; }
        }
        #endregion

        #region ///帮助文档命令
        private SimpleCommand _CmdBDSimHelp = new SimpleCommand();
        private SimpleCommand _CmdBDSimExperimentDoc = new SimpleCommand();
        private SimpleCommand _CmdAboutUs = new SimpleCommand();

        /// <summary>
        /// 打开BDSim帮助
        /// </summary>
        public SimpleCommand CmdBDSimHelp
        {
            get { return _CmdBDSimHelp; }
            set { _CmdBDSimHelp = value; }
        }

        public SimpleCommand CmdBDSimExperimentDoc
        {
            get { return _CmdBDSimExperimentDoc; }
            set { _CmdBDSimExperimentDoc = value; }
        }


        /// <summary>
        /// 关于我们
        /// </summary>
        public SimpleCommand CmdAboutUs
        {
            get { return _CmdAboutUs; }
            set { _CmdAboutUs = value; }
        }
        #endregion

        #region///其他命令定义

        SimpleCommand _CmdResetScenario = new SimpleCommand();
        SimpleCommand _CmdAddExistModels = new SimpleCommand();

        /// <summary>
        /// 重置仿真场景
        /// </summary>
        public SimpleCommand CmdResetScenario
        {
            get { return _CmdResetScenario; }
            set { _CmdResetScenario = value; }
        }

        /// <summary>
        /// 添加模型
        /// </summary>
        public SimpleCommand CmdAddExistModels
        {
            get { return _CmdAddExistModels; }
            set { _CmdAddExistModels = value; }
        }


        #endregion

        #endregion

        #region 注册SimpleCommand命令事件
        void RegisterCommandEvent()
        {
            CmdOpenFile.RegisterCommand(CmdOpenFile_Excute, CmdOpenFile_CanExcute);
            CmdSaveFile.RegisterCommand(CmdSaveFile_Excute, CmdSaveFile_CanExcute);
            CmdPluginManage.RegisterCommand(CmdPluginManage_Excute, CmdPluginManage_CanExcute);
            CmdExportSimData.RegisterCommand(CmdExportSimData_Excute, CmdExportSimData_CanExcute);
            CmdCloseBDSim.RegisterCommand(CmdCloseBDSim_Excute, CmdCloseBDSim_CanExcute);
            CmdRunWizard.RegisterCommand(CmdRunWizard_Excute, CmdRunWizard_CanExcute);

            CmdTimeConvert.RegisterCommand(CmdTimeConvert_Excute, CmdTimeConvert_CanExcute);
            CmdCoordConvert.RegisterCommand(CmdCoordConvert_Excute, CmdCoordConvert_CanExcute);
            CmdNavMsgDecode.RegisterCommand(CmdNavMsgDecode_Excute, CmdNavMsgDecode_CanExcute);
            CmdROD.RegisterCommand(CmdROD_Excute, CmdROD_CanExcute);
            CmdRealDataHandle.RegisterCommand(CmdRealDataHandle_Excute, CmdRealDataHandle_CanExcute);

            CmdScenarioConfig.RegisterCommand(CmdScenarioConfig_Excute, CmdScenarioConfig_CanExcute);
            CmdPropertyConfig.RegisterCommand(CmdPropertyConfig_Excute, CmdPropertyConfig_CanExcute);
            CmdSimMsgReport.RegisterCommand(CmdSimMsgReport_Excute, CmdSimMsgReport_CanExcute);
            CmdThreeDimension.RegisterCommand(CmdThreeDimension_Excute, CmdThreeDimension_CanExcute);
            CmdEarthMap.RegisterCommand(CmdEarthMap_Excute, CmdEarthMap_CanExcute);
            CmdPPEvaluation.RegisterCommand(CmdPPEvaluation_Excute, CmdPPEvaluation_CanExcute);

            CmdSystemSetting.RegisterCommand(CmdSystemSetting_Excute, CmdSystemSetting_CanExcute);

            CmdInit.RegisterCommand(CmdInit_Excute, CmdInit_CanExcute);
            CmdRun.RegisterCommand(CmdRun_Excute, CmdRun_CanExcute);
            CmdPause.RegisterCommand(CmdPause_Excute, CmdPause_CanExcute);
            CmdContinue.RegisterCommand(CmdContinue_Excute, CmdContinue_CanExcute);
            CmdEndRun.RegisterCommand(CmdEndRun_Excute, CmdEndRun_CanExcute);
            CmdRunSlower.RegisterCommand(CmdRunSlower_Excute, CmdRunSlower_CanExcute);
            CmdRunFaster.RegisterCommand(CmdRunFaster_Excute, CmdRunFaster_CanExcute);

            CmdBDSimHelp.RegisterCommand(CmdBDSimHelp_Excute, CmdBDSimHelp_CanExcute);
            CmdBDSimExperimentDoc.RegisterCommand(CmdBDSimExperimentDoc_Excute, CmdBDSimExperimentDoc_CanExcute);
            CmdAboutUs.RegisterCommand(CmdAboutUs_Excute, CmdAboutUs_CanExcute);

            CmdResetScenario.RegisterCommand(CmdResetScenario_Excute, CmdResetScenario_CanExcute);
            CmdAddExistModels.RegisterCommand(CmdAddExistModels_Excute, CmdAddExistModels_CanExcute);

        }
        #endregion

        #region 定义SimpleCommand命令处理事件

        #region 文件栏命令（执行事件）

        #region CmdOpenFile：打开仿真场景文件
        void CmdOpenFile_Excute(object o)
        {
            OpenScenarioFile();
        }

        /// <summary>
        /// 打开场景文件
        /// </summary>
        public bool OpenScenarioFile()
        {
            bool flag = false;
            try
            {
                
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "场景文件(*.sce)|*.sce|场景文件(*.txt)|*.txt";
                if (ofd.ShowDialog() == true)
                {
                    switch (ofd.FilterIndex)
                    {
                        case 1:
                            OpenScenarioData(ofd.FileName);
                            break;
                        case 2:
                            List<string> TrackDataList = new List<string>();
                            string[] strArray = File.ReadAllLines(ofd.FileName, Encoding.Default);
                            foreach (var item in strArray)
                            {
                                TrackDataList.Add(item);
                            }
                           // OpenScenarioData(TrackDataList);
                            break;
                        default:
                            break;
                    }
                    Scenario.EnvironmentSegmentInit();
                    flag = true;
                }
                Directory.SetCurrentDirectory(MainDispatcher.StartPath);
            }
            catch (Exception exp)
            {
                Scenario = new BDSim.Scenario();
                Scenario.EnvironmentSegmentInit();
                MessageBox.Show("场景文件存在不匹配项，打开失败!\r\n" + exp.ToString());
            }
            return flag;
        }

        /// <summary>
        /// 打开XML文档场景
        /// </summary>
        /// <param name="scenarioFile"></param>
        void OpenScenarioData(string scenarioFile)
        {
            string[] strList = scenarioFile.Split(new string[1] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
            string scenarioPath = scenarioFile.Replace("\\" + strList[strList.Count() - 1], "");
            ScenarioXmlData scenarioData = XmlFileOperater<ScenarioXmlData>.LoadFromFile(scenarioFile);
            Scenario = scenarioData.Scenario;
            Scenario.DlgEarthMapUpdate = (Parent as MainWindow).earthMapView.Display;
            foreach (var simpleObject in scenarioData.SimpleObjectList)
            {
                string objectFile = scenarioPath + simpleObject.BaseDataPath;
                int subGroundCount = (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList.Count;
                int StationCollectionCount;
                switch (simpleObject.Type)
                {
                    case SimpleType.Constellation:
                        Constellation constellation = XmlFileOperater<Constellation>.LoadFromFile(objectFile);
                        foreach (var sat in constellation.SatelliteCollection)
                        {
                            sat.Parent = constellation;
                        }
                        (Scenario.SegmentColletion[0] as SpaceSegment).AddConstellation(constellation);
                        break;

                    case SimpleType.EnvSegment:
                        break;
                    case SimpleType.SpaceEnv:
                        break;
                    case SimpleType.ClimeteEnv:
                        break;
                    case SimpleType.IonTecEnv:
                        break;
                    case SimpleType.AstronomyEnv:
                        break;
                    case SimpleType.AstroMotionEnv:
                        break;

                    case SimpleType.SubGroundSegment:
                        SubGroundSegment subGroundSegment = XmlFileOperater<SubGroundSegment>.LoadFromFile(objectFile);
                        (Scenario.SegmentColletion[2] as GroundSegment).AddSubGroundSegment(subGroundSegment);
                        break;
                    case SimpleType.MasterStationList:
                        (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList[subGroundCount - 1].AddStationCollection(new StationCollection() {Name = "主控站", Type = EStationType.MasterStation });
                        break;
                    case SimpleType.InjectionStationList:
                        (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList[subGroundCount - 1].AddStationCollection(new StationCollection() {Name = "注入站", Type = EStationType.InjectionStation });
                        break;
                    case SimpleType.MonitorStationList:
                        (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList[subGroundCount - 1].AddStationCollection(new StationCollection() {Name = "监测站", Type = EStationType.MonitorStation });
                        break;

                    case SimpleType.MasterStation:
                        StationCollectionCount = (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList[subGroundCount - 1].GroundList.Count;
                        MasterStation mas = XmlFileOperater<MasterStation>.LoadFromFile(objectFile);
                        (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList[subGroundCount - 1].GroundList[StationCollectionCount - 1].AddStation(mas);
                        break;
                    case SimpleType.InjectionStation:
                        StationCollectionCount = (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList[subGroundCount - 1].GroundList.Count;
                        InjectionStation inj = XmlFileOperater<InjectionStation>.LoadFromFile(objectFile);
                        
                        (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList[subGroundCount - 1].GroundList[StationCollectionCount - 1].AddStation(inj);
                        foreach (var sender in inj.InjectSendReceivers)
                        {
                            sender.Parent2 = inj;
                            sender.Parent = inj.Parent;
                        }
                        break;
                    case SimpleType.MonitorStation:
                        StationCollectionCount = (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList[subGroundCount - 1].GroundList.Count;
                        MonitorStation mon = XmlFileOperater<MonitorStation>.LoadFromFile(objectFile);
                        (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList[subGroundCount - 1].GroundList[StationCollectionCount - 1].AddStation(mon);
                        foreach (var sender in mon.MonitorReceivers)
                        {
                            sender.Parent = mon;
                        }
                        break;                    
                    case SimpleType.StaticUser:
                        StaticUser staticUser = XmlFileOperater<StaticUser>.LoadFromFile(objectFile);
                        (Scenario.SegmentColletion[3] as UserSegment).AddBaseUser(staticUser);
                        break;
                    case SimpleType.Aircraft:
                        Aircraft aircraft = XmlFileOperater<Aircraft>.LoadFromFile(objectFile);
                        (Scenario.SegmentColletion[3] as UserSegment).AddBaseUser(aircraft);
                        break;
                    case SimpleType.Car:
                        Car car = XmlFileOperater<Car>.LoadFromFile(objectFile);
                        (Scenario.SegmentColletion[3] as UserSegment).AddBaseUser(car);
                        break;
                    case SimpleType.Ship:
                        Ship ship = XmlFileOperater<Ship>.LoadFromFile(objectFile);
                        (Scenario.SegmentColletion[3] as UserSegment).AddBaseUser(ship);
                        break;
                    //case SimpleType.SpaceVehicle:
                    //    SpaceVehicle spaceVehicle = XmlFileOperater<SpaceVehicle>.LoadFromFile(objectFile);
                    //    (Scenario.SegmentColletion[3] as UserSegment).AddBaseUser(spaceVehicle);
                    //    break;
                    //case SimpleType.Missile:
                    //    Missile missile = XmlFileOperater<Missile>.LoadFromFile(objectFile);
                    //    (Scenario.SegmentColletion[3] as UserSegment).AddBaseUser(missile);
                    //    break;
                    case SimpleType.CustomUser:
                        UserDefinedVehicle userDefinedVehicle = XmlFileOperater<UserDefinedVehicle>.LoadFromFile(objectFile);
                        (Scenario.SegmentColletion[3] as UserSegment).AddBaseUser(userDefinedVehicle);
                        break;
                    default:
                        break;
                }
            }
        }

        /// <summary>
        /// 打开文本文档场景
        /// </summary>
        /// <param name="TrackDataList"></param>
        //void OpenScenarioData(List<string> TrackDataList)
        //{
        //    Scenario = new BDSim.Scenario();
        //    int n = 7;
        //    Constellation Constellation = new Constellation() { ISSatCrossLink = true };
        //    Constellation.Name = "Constellation1";
        //    (Scenario.SegmentColletion[0] as SpaceSegment).AddConstellation(Constellation);
        //    SubGroundSegment SubGroundSegment = new SubGroundSegment();

        //    SubGroundSegment.Name = "BD地面段";
        //    StationCollection StationCollection = new BDSim.StationCollection();
        //    StationCollection.Name = "锚固站";
        //    StationCollection.Type = EStationType.AnchoringStation;
        //    SubGroundSegment.AddStationCollection(StationCollection);
        //    (Scenario.SegmentColletion[2] as GroundSegment).AddSubGroundSegment(SubGroundSegment);
        //    string[] str = null;
        //    for (int i = n; i < TrackDataList.Count; i++)
        //    {

        //        str = TrackDataList[i].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //        if (str.Length >= 2 && str[0].Equals("begin"))
        //        {
        //            switch (str[1])
        //            {

        //                case "场景":
        //                    n = i;

        //                    for (n = i + 1; n < TrackDataList.Count; n++)
        //                    {
        //                        UTCTimeClass t = new UTCTimeClass();
        //                        str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                        if (str.Length == 0)
        //                        {
        //                            continue;
        //                        }
        //                        if (str[0].Equals("end") || str[0].Equals("begin"))
        //                        {
        //                            i = n - 1;
        //                            break;
        //                        }
        //                        else
        //                        {

        //                            if (str[0].Equals("开始时间"))
        //                            {

        //                                string[] startTime = TrackDataList[n].Split(new char[4] { ' ', '\t', '/', ':' }, StringSplitOptions.RemoveEmptyEntries);
        //                                t.year = Convert.ToInt32(startTime[1].ToString());
        //                                t.mon = Convert.ToInt32(startTime[2].ToString());
        //                                t.day = Convert.ToInt32(startTime[3].ToString());
        //                                t.hour = Convert.ToInt32(startTime[4].ToString());
        //                                t.min = Convert.ToInt32(startTime[5].ToString());
        //                                t.sec = Convert.ToDouble(startTime[6].ToString());
        //                                Scenario.StartTime = t;
        //                            }
        //                            if (str[0].Equals("结束时间"))
        //                            {
        //                                string[] startTime = TrackDataList[n].Split(new char[4] { ' ', '\t', '/', ':' }, StringSplitOptions.RemoveEmptyEntries);
        //                                t.year = Convert.ToInt32(startTime[1].ToString());
        //                                t.mon = Convert.ToInt32(startTime[2].ToString());
        //                                t.day = Convert.ToInt32(startTime[3].ToString());
        //                                t.hour = Convert.ToInt32(startTime[4].ToString());
        //                                t.min = Convert.ToInt32(startTime[5].ToString());
        //                                t.sec = Convert.ToDouble(startTime[6].ToString());
        //                                Scenario.EndTime = t;
        //                            }
        //                            if (str[0].Equals("当前时间"))
        //                            {
        //                                UTCTime t0 = new UTCTime();
        //                                string[] startTime = TrackDataList[n].Split(new char[4] { ' ', '\t', '/', ':' }, StringSplitOptions.RemoveEmptyEntries);
        //                                t0.year = Convert.ToInt32(startTime[1].ToString());
        //                                t0.mon = Convert.ToInt32(startTime[2].ToString());
        //                                t0.day = Convert.ToInt32(startTime[3].ToString());
        //                                t0.hour = Convert.ToInt32(startTime[4].ToString());
        //                                t0.min = Convert.ToInt32(startTime[5].ToString());
        //                                t0.sec = Convert.ToDouble(startTime[6].ToString());
        //                                Scenario.CurrentTime = t0;
        //                            }
        //                            if (str[0].Equals("仿真步长"))
        //                            {
        //                                Scenario.StepSize = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                            }
        //                            if (str[0].Equals("观测数据仿真开关"))
        //                            {
        //                                Scenario.IsGenerateObsData = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                            }
        //                            if (str[0].Equals("星历拟合仿真开关"))
        //                            {
        //                                Scenario.IsFitEphemeris = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                            }
        //                            if (str[0].Equals("星历拟合误差项开关"))
        //                            {
        //                                Scenario.IsSelected = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                            }
        //                            if (str[0].Equals("接收机定位开关"))
        //                            {
        //                                Scenario.IsPPositioning = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                            }
        //                        }
        //                    }
        //                    break;
        //                case "卫星":
        //                    Satellite st = new Satellite();
        //                    st.SatObsErrFlag = new SatObsErrFlag() { IsOff = true, IsRel = false, IsSatClk = false };
        //                    UTCTimeClass t1 = new UTCTimeClass();
        //                    n = i;
        //                    for (; n < TrackDataList.Count; n++)
        //                    {
        //                        str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                        if (str.Length == 0)
        //                        {
        //                            continue;
        //                        }
        //                        if (str[0].Equals("end"))
        //                        {
        //                            i = n;
        //                            break;
        //                        }
        //                        else
        //                        {
        //                            if (str[0].Equals("编号"))
        //                            {
        //                                st.Id = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                            }
        //                            if (str[0].Equals("名称"))
        //                            {
        //                                st.Name = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString();
        //                            }
        //                            if (str[0].Equals("begin"))
        //                            {
        //                                switch (str[1])
        //                                {
        //                                    case "轨道":
        //                                        int type = 0;
        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {

        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("坐标系统"))
        //                                                {
        //                                                    type = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("轨道历元"))
        //                                                {
        //                                                    UTCTime tt = new UTCTime();
        //                                                    string[] Time = TrackDataList[n].Split(new char[4] { ' ', '\t', '/', ':' }, StringSplitOptions.RemoveEmptyEntries);
        //                                                    tt.year = Convert.ToInt32(Time[1].ToString());
        //                                                    tt.mon = Convert.ToInt32(Time[2].ToString());
        //                                                    tt.day = Convert.ToInt32(Time[3].ToString());
        //                                                    tt.hour = Convert.ToInt32(Time[4].ToString());
        //                                                    tt.min = Convert.ToInt32(Time[5].ToString());
        //                                                    tt.sec = Convert.ToDouble(Time[6].ToString());
        //                                                    st.simParam.pStartTime = tt;
        //                                                }
        //                                                if (str[0].Equals("轨道数据"))
        //                                                {

        //                                                    string[] Data = TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries);
        //                                                    if (type != 1)
        //                                                    {
        //                                                        st.Orbit.InitPV_ECF.x = Convert.ToDouble(Data[1].ToString());
        //                                                        st.Orbit.InitPV_ECF.y = Convert.ToDouble(Data[2].ToString());
        //                                                        st.Orbit.InitPV_ECF.z = Convert.ToDouble(Data[3].ToString());
        //                                                        st.Orbit.InitPV_ECF.vx = Convert.ToDouble(Data[4].ToString());
        //                                                        st.Orbit.InitPV_ECF.vy = Convert.ToDouble(Data[5].ToString());
        //                                                        st.Orbit.InitPV_ECF.vz = Convert.ToDouble(Data[6].ToString());
        //                                                    }
        //                                                    else
        //                                                    {
        //                                                        st.Orbit.InitPV_ECI.x = Convert.ToDouble(Data[1].ToString());
        //                                                        st.Orbit.InitPV_ECI.y = Convert.ToDouble(Data[2].ToString());
        //                                                        st.Orbit.InitPV_ECI.z = Convert.ToDouble(Data[3].ToString());
        //                                                        st.Orbit.InitPV_ECI.vx = Convert.ToDouble(Data[4].ToString());
        //                                                        st.Orbit.InitPV_ECI.vy = Convert.ToDouble(Data[5].ToString());
        //                                                        st.Orbit.InitPV_ECI.vz = Convert.ToDouble(Data[6].ToString());
        //                                                    }

        //                                                }
        //                                            }
        //                                        }
        //                                        st.simParam.simClks = 0;
        //                                        st.simParam.simStepInt = 6;
        //                                        break;
        //                                    case "钟差":

        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n - 1;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("历元"))
        //                                                {
        //                                                    string[] Time = TrackDataList[n].Split(new char[4] { ' ', '\t', '/', ':' }, StringSplitOptions.RemoveEmptyEntries);
        //                                                    t1.year = Convert.ToInt32(Time[1].ToString());
        //                                                    t1.mon = Convert.ToInt32(Time[2].ToString());
        //                                                    t1.day = Convert.ToInt32(Time[3].ToString());
        //                                                    t1.hour = Convert.ToInt32(Time[4].ToString());
        //                                                    t1.min = Convert.ToInt32(Time[5].ToString());
        //                                                    t1.sec = Convert.ToDouble(Time[6].ToString());
        //                                                    st.Clock.Clk_t0 = t1;
        //                                                }
        //                                                if (str[0].Equals("钟差"))
        //                                                {
        //                                                    st.Clock.Clk_b0 = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("钟速"))
        //                                                {
        //                                                    st.Clock.Clk_r0 = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("钟漂"))
        //                                                {
        //                                                    st.Clock.Clk_d0 = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("标准差"))
        //                                                {

        //                                                    st.Clock.Clk_NoiseH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                            }
        //                                        }

        //                                        break;
        //                                    case "观测误差":
        //                                        //  n = i+1;

        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("通道时延"))
        //                                                {
        //                                                    st.SatObsErrFlag.HWBias = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1]);

        //                                                }

        //                                                if (str[0].Equals("标准差"))
        //                                                {
        //                                                    st.SatObsErrFlag.DeltRanThH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1]);

        //                                                }
        //                                            }
        //                                        }

        //                                        break;
        //                                    case "轨道预报参数":
        //                                        // n = i+1;
        //                                        //轨道预报参数是不是力模型的设置？？

        //                                        for (; n < TrackDataList.Count ; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("非球形摄动"))
        //                                                {
        //                                                    string r = TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString();
        //                                                    int s = Convert.ToInt32(r);
        //                                                    if (s == 1)
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.NonSphPert = true;
        //                                                    }
        //                                                    else
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.NonSphPert = false;
        //                                                    }
        //                                                }

        //                                                if (str[0].Equals("重力场模型"))
        //                                                {
        //                                                    int type1 = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());

        //                                                    if (type1 == 0)
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.EarthPotentialModel = EEarthPotentialModel.JGM3;
        //                                                    }
        //                                                }
        //                                                if (str[0].Equals("地球重力场阶数M"))
        //                                                {

        //                                                    st.Orbit.COrbitPredictParam.EarthPotentialM = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("地球重力场阶数N"))
        //                                                {
        //                                                    st.Orbit.COrbitPredictParam.EarthPotentialN = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());

        //                                                }
        //                                                if (str[0].Equals("太阳摄动"))
        //                                                {
        //                                                    int s1 = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());

        //                                                    if (s1 == 1)
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.SunPert = true;
        //                                                    }
        //                                                    else
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.SunPert = false;
        //                                                    }

        //                                                }
        //                                                if (str[0].Equals("月球摄动"))
        //                                                {

        //                                                    int s1 = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());

        //                                                    if (s1 == 1)
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.MoonPert = true;
        //                                                    }
        //                                                    else
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.MoonPert = false;
        //                                                    }

        //                                                }
        //                                                if (str[0].Equals("光压摄动"))
        //                                                {
        //                                                    int s1 = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());

        //                                                    if (s1 == 1)
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.SunSrpPert = true;
        //                                                    }
        //                                                    else
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.SunSrpPert = false;
        //                                                    }


        //                                                } if (str[0].Equals("大气阻力摄动"))
        //                                                {
        //                                                    int s1 = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());

        //                                                    if (s1 == 1)
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.Rel = true;
        //                                                    }
        //                                                    else
        //                                                    {
        //                                                        st.Orbit.COrbitPredictParam.Rel = false;
        //                                                    }


        //                                                }
        //                                                if (str[0].Equals("卫星面积"))
        //                                                {
        //                                                    st.Orbit.COrbitPredictParam.SatArea = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());

        //                                                }
        //                                                if (str[0].Equals("卫星质量"))
        //                                                {
        //                                                    st.Orbit.COrbitPredictParam.SatMass = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());

        //                                                }
        //                                                if (str[0].Equals("光压模型"))
        //                                                {

        //                                                    st.Orbit.COrbitPredictParam.SunSrpModel = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("光压系数"))
        //                                                {

        //                                                    st.Orbit.COrbitPredictParam.SunRprParam[0] = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                            }
        //                                        }
        //                                        break;
        //                                }
        //                            }

        //                        }

        //                    }

        //                    Constellation.SatelliteCollection.Add(st);

        //                    break;
        //                case "锚固站":
        //                    AnchoringStation As = new AnchoringStation();
        //                    n = i;
        //                    for (; n < TrackDataList.Count; n++)
        //                    {
        //                        str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                        if (str.Length == 0)
        //                        {
        //                            continue;
        //                        }
        //                        if (str[0].Equals("end"))
        //                        {
        //                            i = n - 1;
        //                            break;
        //                        }
        //                        else
        //                        {
        //                            if (str[0].Equals("编号"))
        //                            {
        //                                As.Id = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                            }
        //                            if (str[0].Equals("名称"))
        //                            {
        //                                As.Name = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString();

        //                            }
        //                            if (str[0].Equals("begin"))
        //                            {
        //                                switch (str[1])
        //                                {
        //                                    case "轨道":
        //                                        int type = 0;
        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n - 1;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("坐标系统"))
        //                                                {
        //                                                    type = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("轨道历元"))
        //                                                {
        //                                                    //  gj.gj_utc = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1] + " " + TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2]; ;
        //                                                }
        //                                                if (str[0].Equals("轨道数据"))
        //                                                {
        //                                                    if (type == 0)
        //                                                    {
        //                                                        As.Pos_XYZ.X = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                        As.Pos_XYZ.Y = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());
        //                                                        As.Pos_XYZ.Z = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[3].ToString());
        //                                                    }
        //                                                    else if (type == 1) //把ECI转成ECF再赋值
        //                                                    {
        //                                                        NodePosVel ECI_pv = new NodePosVel();
        //                                                        NodePosVel ECF_pv = new NodePosVel();
        //                                                        ECI_pv.X = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                        ECI_pv.Y = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());
        //                                                        ECI_pv.Z = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[3].ToString());
        //                                                        TimeSpaceDll.ECI2ECF(ECI_pv, 0, 0, out ECF_pv);
        //                                                        As.Pos_XYZ.X = ECF_pv.X;
        //                                                        As.Pos_XYZ.Y = ECF_pv.Y;
        //                                                        As.Pos_XYZ.Z = ECF_pv.Z;
        //                                                    }

        //                                                }
        //                                            }
        //                                        }

        //                                        break;
        //                                    case "钟差":

        //                                        StationClock stc = new StationClock();
        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            UTCTimeClass t = new UTCTimeClass();
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("历元"))
        //                                                {
        //                                                    string[] Time = TrackDataList[n].Split(new char[4] { ' ', '\t', '/', ':' }, StringSplitOptions.RemoveEmptyEntries);
        //                                                    t.year = Convert.ToInt32(Time[1].ToString());
        //                                                    t.mon = Convert.ToInt32(Time[2].ToString());
        //                                                    t.day = Convert.ToInt32(Time[3].ToString());
        //                                                    t.hour = Convert.ToInt32(Time[4].ToString());
        //                                                    t.min = Convert.ToInt32(Time[5].ToString());
        //                                                    t.sec = Convert.ToDouble(Time[6].ToString());
        //                                                    stc.Clk_t0 = t;

        //                                                }
        //                                                if (str[0].Equals("钟差"))
        //                                                {
        //                                                    stc.Clk_b0 = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("钟速"))
        //                                                {
        //                                                    stc.Clk_r0 = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("钟漂"))
        //                                                {
        //                                                    stc.Clk_d0 = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("标准差"))
        //                                                {
        //                                                    stc.Clk_NoiseH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                            }
        //                                        }

        //                                        As.CStationClock = stc;
        //                                        break;


        //                                    case "接收机":
        //                                        SendReceiveDevice srd = new SendReceiveDevice();
        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("名称"))
        //                                                {
        //                                                    srd.Name = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString();
        //                                                }
        //                                                if (str[0].Equals("编号"))
        //                                                {
        //                                                    srd.Id = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("截止高度角"))
        //                                                {
        //                                                    srd.Elelim = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("频点值"))
        //                                                {
        //                                                    srd.Frequency = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("伪距噪声量级"))
        //                                                {
        //                                                    srd.PseudoRanThH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("载波相位噪声量级"))
        //                                                {
        //                                                    srd.CarrRanThH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("控制开关"))
        //                                                {
        //                                                    srd.ErrFlag.IsIion = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                    srd.ErrFlag.IsImul = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());
        //                                                    srd.ErrFlag.IsIoff = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[3].ToString());

        //                                                    srd.ErrFlag.IsIrel = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[4].ToString());
        //                                                    srd.ErrFlag.IsItro = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[5].ToString());
        //                                                    srd.ErrFlag.IsSatClk = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[6].ToString());
        //                                                    srd.ErrFlag.IsStaClk = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[7].ToString());
        //                                                }
        //                                                if (str[0].Equals("相对偏移量"))
        //                                                {
        //                                                    srd.U_Off.E = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                    srd.U_Off.N = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());
        //                                                    srd.U_Off.U = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[3].ToString());
        //                                                }
        //                                            }

        //                                        }

        //                                        As.AnchoringSendReceivers.Add(srd);
        //                                        break;
        //                                    case "观测误差":
        //                                        //gcwc gc1 = new gcwc();

        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("通道时延"))
        //                                                {
        //                                                    As.AnchoringSendReceivers[0].HWBias = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }

        //                                                if (str[0].Equals("标准差"))
        //                                                {
        //                                                    As.AnchoringSendReceivers[0].PseudoRanThH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("对流层误差模型"))
        //                                                {
        //                                                    //As.AnchoringSendReceivers[0].ErrFlag.IsItro = Convert.ToBoolean((uint)0);
        //                                                    As.AnchoringSendReceivers[0].ErrFlag.IsItro = Convert.ToBoolean(Convert.ToUInt16(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString()));
        //                                                }
        //                                            }

        //                                        }
        //                                        break;
        //                                }
        //                            }

        //                        }

        //                    }
        //                    As.Type = EStationType.AnchoringStation;

        //                    StationCollection.AddStation(As);
        //                    break;
        //                case "静止用户":
        //                    n = i;
        //                    StaticUser su = new StaticUser();
        //                    for (; n < TrackDataList.Count; n++)
        //                    {
        //                        str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                        if (str.Length == 0)
        //                        {
        //                            continue;
        //                        }
        //                        if (str[0].Equals("end"))
        //                        {
        //                            i = n - 1;
        //                            break;
        //                        }
        //                        else
        //                        {
        //                            if (str[0].Equals("编号"))
        //                            {
        //                                su.Id = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                            }
        //                            if (str[0].Equals("名称"))
        //                            {
        //                                su.Name = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString();

        //                            }
        //                            if (str[0].Equals("begin"))
        //                            {
        //                                switch (str[1])
        //                                {
        //                                    case "轨道":

        //                                        int type = 0;
        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n - 1;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {

        //                                                if (str[0].Equals("坐标系统"))
        //                                                {

        //                                                    type = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("轨道历元"))
        //                                                {

        //                                                    // gj.gj_utc = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1] + " " + TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2]; ;
        //                                                }
        //                                                if (str[0].Equals("轨道数据"))
        //                                                {
        //                                                    if (type == 1)
        //                                                    {
        //                                                        su.UserPosXYZ.X = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                        su.UserPosXYZ.Y = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());
        //                                                        su.UserPosXYZ.Z = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[3].ToString());
        //                                                    }
        //                                                    else
        //                                                    {
        //                                                        su.UserPosBLH.B = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                        su.UserPosBLH.L = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());
        //                                                        su.UserPosBLH.H = Convert.ToDouble(TrackDataList[n].Split(new char[3] { ' ', '\t', '#' }, StringSplitOptions.RemoveEmptyEntries)[3].ToString());
        //                                                    }

        //                                                }
        //                                            }
        //                                        }

        //                                        break;
        //                                    case "钟差":
        //                                        StationClock stc = new StationClock();
        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            UTCTimeClass t = new UTCTimeClass();
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("历元"))
        //                                                {
        //                                                    string[] Time = TrackDataList[n].Split(new char[4] { ' ', '\t', '/', ':' }, StringSplitOptions.RemoveEmptyEntries);
        //                                                    t.year = Convert.ToInt32(Time[1].ToString());
        //                                                    t.mon = Convert.ToInt32(Time[2].ToString());
        //                                                    t.day = Convert.ToInt32(Time[3].ToString());
        //                                                    t.hour = Convert.ToInt32(Time[4].ToString());
        //                                                    t.min = Convert.ToInt32(Time[5].ToString());
        //                                                    t.sec = Convert.ToDouble(Time[6].ToString());
        //                                                    stc.Clk_t0 = t;

        //                                                }
        //                                                if (str[0].Equals("钟差"))
        //                                                {
        //                                                    stc.Clk_b0 = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("钟速"))
        //                                                {
        //                                                    stc.Clk_r0 = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("钟漂"))
        //                                                {
        //                                                    stc.Clk_d0 = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("标准差"))
        //                                                {
        //                                                    stc.Clk_NoiseH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                            }
        //                                        }

        //                                        break;
        //                                    case "观测误差":
        //                                        //gcwc gc1 = new gcwc();

        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("通道时延"))
        //                                                {
        //                                                    //gc1.tdys = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];

        //                                                }

        //                                                if (str[0].Equals("标准差"))
        //                                                {
        //                                                    //gc1.gc_E = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];
        //                                                }
        //                                                if (str[0].Equals("对流层误差模型"))
        //                                                {
        //                                                    //gc1.dlc = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];
        //                                                }
        //                                            }

        //                                        }

        //                                        break;

        //                                    case "接收机":
        //                                        CReceiver cr = new CReceiver();
        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("名称"))
        //                                                {
        //                                                    cr.Name = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString();
        //                                                }
        //                                                if (str[0].Equals("编号"))
        //                                                {
        //                                                    cr.Id = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("截止高度角"))
        //                                                {
        //                                                    cr.Elelim = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("RTK"))
        //                                                {
        //                                                    cr.IsRTK = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("伪距噪声量级"))
        //                                                {
        //                                                    cr.PseudoRanThH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("载波相位噪声量级"))
        //                                                {
        //                                                    cr.CarrRanThH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("控制开关"))
        //                                                {
        //                                                    cr.ObsErrCtrlFlag.IsIion = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsImul = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsIoff = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[3].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsIrel = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[4].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsItro = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[5].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsSatClk = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[6].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsStaClk = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[7].ToString());
        //                                                }
        //                                                if (str[0].Equals("安装位置"))
        //                                                {
        //                                                    cr.DeltaPos_X = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                    cr.DeltaPos_Y = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());
        //                                                    cr.DeltaPos_Z = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[3].ToString());
        //                                                }
        //                                                if (str[0].Equals("业务控制"))
        //                                                {
        //                                                    cr.IsGenObsData = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                    cr.IsPosition = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());

        //                                                }

        //                                                if (str[0].Equals("定位模式类型"))
        //                                                {

        //                                                }
        //                                            }

        //                                        }
        //                                        su.RecCollection.Add(cr);
        //                                        break;
        //                                }
        //                            }

        //                        }

        //                    }
        //                    //  su.Type = EUserType.StaticUser;
        //                    (Scenario.SegmentColletion[3] as UserSegment).AddBaseUser(su);
        //                    break;
        //                case "汽车用户":
        //                    n = i;
        //                    Car car = new Car();
        //                    for (; n < TrackDataList.Count; n++)
        //                    {
        //                        str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                        if (str.Length == 0)
        //                        {
        //                            continue;
        //                        }
        //                        if (str[0].Equals("end"))
        //                        {
        //                            i = n - 1;
        //                            break;
        //                        }
        //                        else
        //                        {
        //                            if (str[0].Equals("编号"))
        //                            {
        //                                car.Id = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                            }
        //                            if (str[0].Equals("名称"))
        //                            {
        //                                car.Name = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];

        //                            }
        //                            if (str[0].Equals("begin"))
        //                            {
        //                                switch (str[1])
        //                                {
        //                                    case "轨迹":
        //                                        int type = 0;
        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n - 1;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("轨迹模式"))
        //                                                {
        //                                                    type = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1]);
        //                                                }
        //                                                if (str[0].Equals("轨迹路径"))
        //                                                {
        //                                                    //if (type == 0)
        //                                                    //{
        //                                                    //    string Nath = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];
        //                                                    //    OpenFileDialog OpenFile = new OpenFileDialog();
        //                                                    //    string[] strArray = File.ReadAllLines(OpenFile.FileName);
        //                                                    //    foreach (var item in strArray)
        //                                                    //    {
        //                                                    //        TrackDataList.Add(item);
        //                                                    //    }

        //                                                    //    if (TrackDataList.Count >= 6)
        //                                                    //    {
        //                                                    //        for (int j = 6; j < TrackDataList.Count; i++)
        //                                                    //        {
        //                                                    //            //line = i;
        //                                                    //            if (!TrackDataList[j].Equals(""))
        //                                                    //            {
        //                                                    //                NodePosVel xyz = new NodePosVel();

        //                                                    //                string[] splitStringList = TrackDataList[j].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

        //                                                    //                xyz.X = Convert.ToDouble(splitStringList[5]);
        //                                                    //                xyz.Y = Convert.ToDouble(splitStringList[6]);
        //                                                    //                xyz.Z = Convert.ToDouble(splitStringList[7]);
        //                                                    //                car.PosVelXYZList.Add(xyz);
        //                                                    //            }


        //                                                    //        }
        //                                                    //    }
        //                                                    //    else
        //                                                    //    {
        //                                                    //        System.Windows.MessageBox.Show("用户轨迹文件没有轨迹数据！");
        //                                                    //    }
        //                                                    //}
        //                                                }
        //                                            }
        //                                        }

        //                                        break;
        //                                    case "钟差":
        //                                        //zhongc zc1 = new zhongc();
        //                                        //  n = i+1;
        //                                        //for (; n < TrackDataList.Count; n++)
        //                                        //{
        //                                        //    str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                        //    if (str[0].Equals("end"))
        //                                        //    {
        //                                        //        i = n;
        //                                        //        break;
        //                                        //    }
        //                                        //    else
        //                                        //    {
        //                                        //        if (str[0].Equals("历元"))
        //                                        //        {
        //                                        //            zc1.z_utc = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1] + " " + TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2]; ;

        //                                        //        }
        //                                        //        if (str[0].Equals("钟差"))
        //                                        //        {
        //                                        //            zc1.c_a0 = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];
        //                                        //        }
        //                                        //        if (str[0].Equals("钟速"))
        //                                        //        {
        //                                        //            zc1.c_a1 = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];
        //                                        //        }
        //                                        //        if (str[0].Equals("钟漂"))
        //                                        //        {
        //                                        //            zc1.c_a2 = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];
        //                                        //        }
        //                                        //        if (str[0].Equals("标准差"))
        //                                        //        {
        //                                        //            zc1.c_E = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];
        //                                        //        }
        //                                        //    }
        //                                        //}


        //                                        break;
        //                                    case "观测误差":
        //                                        //gcwc gc1 = new gcwc();
        //                                        //for (; n < TrackDataList.Count; n++)
        //                                        //{
        //                                        //    str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                        //    if (str[0].Equals("end"))
        //                                        //    {
        //                                        //        i = n;
        //                                        //        break;
        //                                        //    }
        //                                        //    else
        //                                        //    {
        //                                        //        if (str[0].Equals("通道时延"))
        //                                        //        {
        //                                        //            gc1.tdys = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];

        //                                        //        }

        //                                        //        if (str[0].Equals("标准差"))
        //                                        //        {
        //                                        //            gc1.gc_E = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];
        //                                        //        }
        //                                        //        if (str[0].Equals("对流层误差模型"))
        //                                        //        {
        //                                        //            gc1.dlc = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1];
        //                                        //        }
        //                                        //    }

        //                                        //}

        //                                        break;
        //                                    case "接收机":
        //                                        CReceiver cr = new CReceiver();
        //                                        for (; n < TrackDataList.Count; n++)
        //                                        {
        //                                            str = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        //                                            if (str.Length == 0)
        //                                            {
        //                                                continue;
        //                                            }
        //                                            if (str[0].Equals("end"))
        //                                            {
        //                                                i = n;
        //                                                break;
        //                                            }
        //                                            else
        //                                            {
        //                                                if (str[0].Equals("名称"))
        //                                                {
        //                                                    cr.Name = TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString();
        //                                                }
        //                                                if (str[0].Equals("编号"))
        //                                                {
        //                                                    cr.Id = Convert.ToInt32(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("截止高度角"))
        //                                                {
        //                                                    cr.Elelim = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("RTK"))
        //                                                {
        //                                                    cr.IsRTK = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("伪距噪声量级"))
        //                                                {
        //                                                    cr.PseudoRanThH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("载波相位噪声量级"))
        //                                                {
        //                                                    cr.CarrRanThH = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                }
        //                                                if (str[0].Equals("控制开关"))
        //                                                {
        //                                                    cr.ObsErrCtrlFlag.IsIion = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsImul = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsIoff = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[3].ToString());

        //                                                    cr.ObsErrCtrlFlag.IsIrel = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[4].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsItro = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[5].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsSatClk = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[6].ToString());
        //                                                    cr.ObsErrCtrlFlag.IsStaClk = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[7].ToString());
        //                                                }
        //                                                if (str[0].Equals("安装位置"))
        //                                                {
        //                                                    cr.DeltaPos_X = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                    cr.DeltaPos_Y = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());
        //                                                    cr.DeltaPos_Z = Convert.ToDouble(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[3].ToString());
        //                                                }
        //                                                if (str[0].Equals("业务控制"))
        //                                                {
        //                                                    cr.IsGenObsData = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].ToString());
        //                                                    cr.IsPosition = Convert.ToBoolean(TrackDataList[n].Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)[2].ToString());

        //                                                }

        //                                                if (str[0].Equals("定位模式类型"))
        //                                                {

        //                                                }
        //                                                if (str[0].Equals("安装位置"))
        //                                                { }
        //                                            }

        //                                        }
        //                                        car.RecCollection.Add(cr);
        //                                        break;
        //                                }
        //                            }

        //                        }

        //                    }
        //                    (Scenario.SegmentColletion[3] as UserSegment).AddBaseUser(car);
        //                    break;


        //            }
        //        }

        //    }
        //}

        bool CmdOpenFile_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region CmdSaveFile：保存仿真场景文件
        void CmdSaveFile_Excute(object o)
        {
            try
            {
                System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
                if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SaveScenarioData(fbd.SelectedPath);
                    MessageBox.Show("保存成功!");
                }
                Directory.SetCurrentDirectory(MainDispatcher.StartPath);
            }
            catch (Exception exp)
            {
                MessageBox.Show("保存场景出错!\r\n"+ exp.ToString());
            }
        }

        void SaveScenarioData(string path)
        {
            ScenarioXmlData data = new ScenarioXmlData();
            data.Scenario = Scenario;
            string newPath = path + "\\" + Scenario.Name;
            string absolutePath = newPath;
            //创建保存场景的路径
            int pathIndex = 1;
            while (Directory.Exists(absolutePath))
            {
                absolutePath = newPath + "(" + pathIndex + ")";
                pathIndex++;
            }
            Directory.CreateDirectory(absolutePath);
            string relativePath = "";

            #region 保存空间段、星座
            string spaceSegmentPath = "\\空间段";
            Directory.CreateDirectory(absolutePath + spaceSegmentPath);
            foreach (var constellation in (Scenario.SegmentColletion[0] as SpaceSegment).ConstellationList)
            {
                relativePath = spaceSegmentPath +"\\"+  constellation.Name + ".cst";
                data.SimpleObjectList.Add(new SimpleObject() { Name = constellation.Name, Type = SimpleType.Constellation, BaseDataPath = relativePath });
                //保存星座数据
                XmlFileOperater<Constellation>.SaveToFile(absolutePath + relativePath, constellation);
            }
            #endregion

            #region 保存地面控制段
            string groundSegmentPath = "\\地面控制段";
            Directory.CreateDirectory(absolutePath + groundSegmentPath);
            foreach (var subGround in (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList)
            {
                string subGroundPath = "\\" + subGround.Name;
                Directory.CreateDirectory(absolutePath + groundSegmentPath + subGroundPath);
                relativePath = groundSegmentPath + subGroundPath + "\\" + subGround.Name + ".sgs";
                //保存子地面段
                XmlFileOperater<SubGroundSegment>.SaveToFile(absolutePath + relativePath, subGround);
                data.SimpleObjectList.Add(new SimpleObject() { Name = subGround.Name, Type = SimpleType.SubGroundSegment, BaseDataPath = relativePath });
                foreach (var stationList in subGround.GroundList)
                {
                    string stationListPath = "\\" + stationList.Name;
                    Directory.CreateDirectory(absolutePath + groundSegmentPath + subGroundPath + stationListPath);
                    switch (stationList.Type)
                    {
                        case EStationType.MasterStation:
                            data.SimpleObjectList.Add(new SimpleObject() { Name = stationList.Name, Type = SimpleType.MasterStationList });
                            foreach (var station in stationList.StationList)
                            {
                                relativePath = groundSegmentPath + subGroundPath + stationListPath + "\\" + station.Name + ".mst";
                                //保存主控站
                                XmlFileOperater<MasterStation>.SaveToFile(absolutePath + relativePath, (MasterStation)station);
                                data.SimpleObjectList.Add(new SimpleObject() { Name = station.Name, Type = SimpleType.MasterStation, BaseDataPath =  relativePath});
                            }
                            break;
                        case EStationType.InjectionStation:
                            data.SimpleObjectList.Add(new SimpleObject() { Name = stationList.Name, Type = SimpleType.InjectionStationList });
                            foreach (var station in stationList.StationList)
                            {
                                relativePath = groundSegmentPath + subGroundPath + stationListPath + "\\" + station.Name + ".inj";
                                //保存主控站
                                XmlFileOperater<InjectionStation>.SaveToFile(absolutePath + relativePath, (InjectionStation)station);
                                data.SimpleObjectList.Add(new SimpleObject() { Name = station.Name, Type = SimpleType.InjectionStation, BaseDataPath = relativePath });
                            }
                            break;
                        case EStationType.MonitorStation:
                            data.SimpleObjectList.Add(new SimpleObject() { Name = stationList.Name, Type = SimpleType.MonitorStationList });
                            foreach (var station in stationList.StationList)
                            {
                                relativePath = groundSegmentPath + subGroundPath + stationListPath + "\\" + station.Name + ".mon";
                                //保存主控站
                                XmlFileOperater<MonitorStation>.SaveToFile(absolutePath + relativePath, (MonitorStation)station);
                                data.SimpleObjectList.Add(new SimpleObject() { Name = station.Name, Type = SimpleType.MonitorStation, BaseDataPath = relativePath });
                            }
                            break;

                        default:
                            break;
                    }
                }
            }
            #endregion

            #region 保存用户段
            string userSegmentPath = "\\用户段";
            Directory.CreateDirectory(absolutePath + userSegmentPath);
            foreach (var user in (Scenario.SegmentColletion[3] as UserSegment).UserModelList)
            {
                string userPath = "\\" + user.Name;
                Directory.CreateDirectory(absolutePath + userSegmentPath + userPath);
                relativePath = userSegmentPath + userPath + "\\" + user.Name + ".use";
                SimpleType simpleType = SimpleType.StaticUser;
                switch (user.Type)
                {
                    case EUserType.StaticUser:
                        //保存静态用户
                        XmlFileOperater<StaticUser>.SaveToFile(absolutePath + relativePath, (StaticUser)user);
                        simpleType = SimpleType.StaticUser;
                        break;
                    case EUserType.Car:
                        //保存汽车用户
                        XmlFileOperater<Car>.SaveToFile(absolutePath + relativePath, (Car)user);
                        simpleType = SimpleType.Car;
                        break;
                    case EUserType.Aircraft:
                        //保存飞机用户
                        XmlFileOperater<Aircraft>.SaveToFile(absolutePath + relativePath, (Aircraft)user);
                        simpleType = SimpleType.Aircraft;
                        break;
                    case EUserType.Boat:
                        //保存轮船用户
                        XmlFileOperater<Ship>.SaveToFile(absolutePath + relativePath, (Ship)user);
                        simpleType = SimpleType.Ship;
                        break;
                    //case EUserType.Missile:
                    //    //保存弹箭用户
                    //    XmlFileOperater<Missile>.SaveToFile(absolutePath + relativePath, (Missile)user);
                    //    simpleType = SimpleType.Missile;
                    //    break;
                    //case EUserType.SpaceVehicle:
                    //    //保存航天器用户
                    //    XmlFileOperater<SpaceVehicle>.SaveToFile(absolutePath + relativePath, (SpaceVehicle)user);
                    //    simpleType = SimpleType.SpaceVehicle;
                    //    break;
                    case EUserType.CustomUser:
                        //保存自定义用户
                        XmlFileOperater<UserDefinedVehicle>.SaveToFile(absolutePath + relativePath, (UserDefinedVehicle)user);
                        simpleType = SimpleType.CustomUser;
                        break;
                    default:
                        break;
                }
                data.SimpleObjectList.Add(new SimpleObject() { Name = user.Name, Type = simpleType, BaseDataPath = relativePath });
                //foreach (var rec in user.RecCollection)
                //{
                //    relativePath = userSegmentPath + userPath + "\\" + rec.Name + ".rec";
                //    XmlFileOperater<CReceiver>.SaveToFile(absolutePath + relativePath, (CReceiver)rec);
                //    data.SimpleObjectList.Add(new SimpleObject() { Name = rec.Name, Type = SimpleType.Receiver, BaseDataPath = relativePath });
                //}
            }
            #endregion

            #region 保存仿真场景
            XmlFileOperater<ScenarioXmlData>.SaveToFile(absolutePath + "\\" + Scenario.Name + ".sce", data);
            #endregion
        }
        
        bool CmdSaveFile_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region CmdExportSimData：导出仿真数据
        void CmdExportSimData_Excute(object o)
        {

        }

        bool CmdExportSimData_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region CmdPluginManage：BDSim插件管理
        void CmdPluginManage_Excute(object o)
        {
            PluginManager pluginManager = new PluginManager();
            pluginManager.DataContext = this;
            pluginManager.ShowDialog();
        }

        bool CmdPluginManage_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region CmdCloseBDSim：退出BDSim软件平台
        void CmdCloseBDSim_Excute(object o)
        {

        }

        bool CmdCloseBDSim_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region CmdRunWizard：启动用户向导
        void CmdRunWizard_Excute(object o)
        {

        }

        bool CmdRunWizard_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #endregion

        #region 数据处理栏命令（执行事件）

        #region CmdTimeConvert：时间转换
        void CmdTimeConvert_Excute(object o)
        {

        }

        bool CmdTimeConvert_CanExcute(object o)
        {
            bool flag = false;
            return flag;
        }
        #endregion

        #region CmdCoordConvert：坐标转换
        void CmdCoordConvert_Excute(object o)
        {

        }

        bool CmdCoordConvert_CanExcute(object o)
        {
            bool flag = false;
            return flag;
        }
        #endregion

        #region CmdNavMsgDecode：导航电文解析
        void CmdNavMsgDecode_Excute(object o)
        {

        }

        bool CmdNavMsgDecode_CanExcute(object o)
        {
            bool flag = false;
            return flag;
        }
        #endregion

        #region CmdROD：主控站定轨
        void CmdROD_Excute(object o)
        {

        }

        bool CmdROD_CanExcute(object o)
        {
            bool flag = false;
            return flag;
        }
        #endregion

        #region CmdRealDataHandle：实测数据处理
        void CmdRealDataHandle_Excute(object o)
        {
            RealDataHandleWnd realDataHandleWnd = new RealDataHandleWnd();
            realDataHandleWnd.Owner = Parent;
            realDataHandleWnd.Show();
        }

        bool CmdRealDataHandle_CanExcute(object o)
        {
            bool flag = false;
            if (Scenario.Status != ESimStatus.UnInited && Scenario.Status != ESimStatus.End)
            {
                flag = false;
            }
            return flag;
        }
        #endregion

        #endregion

        #region 视图命令（执行事件）

        #region CmdScenarioConfig：仿真场景配置窗口显示
        void CmdScenarioConfig_Excute(object o)
        {
            (Parent as MainWindow).ScenarioViewable();
        }

        bool CmdScenarioConfig_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region CmdPropertyConfig：属性参数配置窗口显示
        void CmdPropertyConfig_Excute(object o)
        {
            (Parent as MainWindow).PropertyViewable();
        }

        bool CmdPropertyConfig_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion
        
        #region CmdSimMsgReport：仿真消息报告窗口显示
        void CmdSimMsgReport_Excute(object o)
        {
            (Parent as MainWindow).SysMsgViewable();
        }

        bool CmdSimMsgReport_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region CmdPPEvaluation：用户定位评估窗口显示
        void CmdPPEvaluation_Excute(object o)
        {
            (Parent as MainWindow).ADockPPositioningViewable();
        }

        bool CmdPPEvaluation_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region  CmdThreeDimension：三维可视化窗口显示
        void CmdThreeDimension_Excute(object o)
        {
            (Parent as MainWindow)._3DViewable();
        }

        bool CmdThreeDimension_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region CmdEarthMap：二维地图可视化窗口显示
        void CmdEarthMap_Excute(object o)
        {
            (Parent as MainWindow)._2DViewable();
        }

        bool CmdEarthMap_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #endregion

        #region 设置栏命令(执行事件)

        #region CmdSystemSetting：BDSin软件系统设置
        void CmdSystemSetting_Excute(object o)
        {

        }

        bool CmdSystemSetting_CanExcute(object o)
        {
            bool flag = false;
            return flag;
        }
        #endregion

        #endregion

        #region 仿真控制命令(执行事件)

        #region CmdInit：仿真初始化
        void CmdInit_Excute(object o)
        {
            Scenario.ClearMissionData();
            MissionProgress ProgressMonitorWnd = new MissionProgress();
            ProgressMonitorWnd.Owner = Parent;
            ProgressMonitorWnd.Focusable = false;
            //使场景成为任务监控窗口的数据源，任务监控窗口的进度条可以随着任务进度进行显示
            ProgressMonitorWnd.DataContext = this.Scenario;
            ProgressMonitorWnd.Show();
            Parent.Focusable = true;
            Parent.Focus();
            
            Thread DataSimThread;
            DataSimThread = new Thread(Init) { Name = "OrbitClkSimThread" };
            DataSimThread.Start();

            //Init();
            
        }

        private void Init()
        {
            //MainDispatcher.MainWindowDispatcher.Invoke(new Action(() =>
            //{
            //    MissionProgress ProgressMonitorWnd = new MissionProgress();
            //    ProgressMonitorWnd.Owner = Parent;
            //    ProgressMonitorWnd.Focusable = false;
            //    //使场景成为任务监控窗口的数据源，任务监控窗口的进度条可以随着任务进度进行显示
            //    ProgressMonitorWnd.DataContext = this.Scenario;
            //    ProgressMonitorWnd.Show();
            //    Parent.Focusable = true;
            //    Parent.Focus();
            //}));
            Scenario.DlgEarthMapUpdate = (Parent as MainWindow).earthMapView.Display;
            Scenario.Init();
            MainDispatcher.MainWindowDispatcher.BeginInvoke(new Action(() =>
            {
                (Parent as MainWindow).view3DScenario.Init();
                (Parent as MainWindow).earthMapView.EarthMapInit();
                (Parent as MainWindow).receiverMonitorView.Init();
            }));

            
            if (Scenario.STKFlag)
            {
                MainDispatcher.MainWindowDispatcher.Invoke(new Action(() =>
                {
                   // (Parent as MainWindow).LoadSTKPlugin();
                    DateTime start = BDSimObject.GlobalStartTime.ToDateTime();
                    DateTime end = BDSimObject.GlobalEndTime.ToDateTime();
                    foreach (var item in Scenario.stkPluginList)
                    {
                        item.SetSTKInitTime(start, end);
                    }
                    if (Scenario.stkPluginList.Count>0)
                    {
                        SaveSatPV();
                        SaveStation();
                    }
                    
                    string SimFile = null;
                    switch (Scenario.ScenarioType)
                    {
                        case PlayScenarioType.CreateNew:
                            break;
                        case PlayScenarioType.Navigation:
                            SimFile = @".\STKDemo\Aircraft\Aircraft.sc";
                            break;
                        case PlayScenarioType.ShenZhou:
                            SimFile = @".\STKDemo\神舟飞船场景\shenzhou.sc";
                            break;
                        case PlayScenarioType.AMM:
                            SimFile = @".\STKDemo\AMM\STK9_AMM.sc";
                            break;
                        case PlayScenarioType.UAV:
                            SimFile = @".\STKDemo\UAV\UAV.sc";
                            break;
                        case PlayScenarioType.LaunchVehicle:
                            SimFile = @".\STKDemo\火箭军\Scenario.sc";
                            break;
                        default:
                            break;
                    }
                    if (File.Exists(SimFile))
                    {
                        foreach (var item in Scenario.stkPluginList)
                        {
                            item.STKNewInit(BDSimObject.GlobalStepSize, false, SimFile);
                        }
                        //Scenario.stkPluginList[0].STKNewInit(BDSimObject.GlobalStepSize, false, SimFile);
                    }
                    else
                    {
                        foreach (var item in Scenario.stkPluginList)
                        {
                            item.STKNewInit(BDSimObject.GlobalStepSize, true);
                        }
                        //Scenario.stkPluginList[0].STKNewInit(BDSimObject.GlobalStepSize, true);
                    }

                }));
            }
        }

        bool CmdInit_CanExcute(object o)
        {
            bool flag = false;
            if (BDSimObject.GlobalStatus == ESimStatus.UnInited || BDSimObject.GlobalStatus == ESimStatus.End)
            {
                flag = true;
            }
            return flag;
        }
        #endregion

        #region CmdRun：仿真运行
        void CmdRun_Excute(object o)
        {
            Scenario.Run();
            (Parent as MainWindow).receiverMonitorView.Init();//主要是为了再次开始运行时清除所有的评估图表,kj
            //if (Scenario.stkPluginList != null)
            //{
            //    Scenario.stkPluginList[0].STKStart();
            //}
            foreach (var item in Scenario.stkPluginList)
            {
                item.STKStart();
            }
        }
        bool CmdRun_CanExcute(object o)
        {
            bool flag = false;
            if (BDSimObject.GlobalStatus == ESimStatus.Inited)
            {
                flag = true;
            }
            return flag;
        }
        #endregion

        #region CmdPause：仿真暂停
        void CmdPause_Excute(object o)
        {
            Scenario.Pause();
            //if (Scenario.stkPluginList != null)
            //{
            //    Scenario.stkPluginList[0].STKPuase();
            //}
            foreach (var item in Scenario.stkPluginList)
            {
                item.STKPuase();
            }
        }

        bool CmdPause_CanExcute(object o)
        {
            bool flag = false;
            if (BDSimObject.GlobalStatus == ESimStatus.Run)
            {
                flag = true;
            }
            return flag;
        }
        #endregion

        #region CmdContinue：仿真继续
        void CmdContinue_Excute(object o)
        {
            Scenario.Continue();
            //if (Scenario.stkPluginList != null)
            //{
            //    Scenario.stkPluginList[0].STKResume();
            //}
            foreach (var item in Scenario.stkPluginList)
            {
                item.STKResume();
            }
        }

        bool CmdContinue_CanExcute(object o)
        {
            bool flag = false;
            if (BDSimObject.GlobalStatus == ESimStatus.Pause)
            {
                flag = true;
            }
            return flag;
        }
        #endregion

        #region CmdEndRun：结束仿真运行
        void CmdEndRun_Excute(object o)
        {
            Scenario.End();
            (Parent as MainWindow).view3DScenario.End();
            //if (Scenario.stkPluginList != null)
            //{
            //    Scenario.stkPluginList[0].STKEnd();
            //}
            foreach (var item in Scenario.stkPluginList)
            {
                item.STKEnd();
            }
        }

        bool CmdEndRun_CanExcute(object o)
        {
            bool flag = false;
            if (BDSimObject.GlobalStatus != ESimStatus.UnInited && BDSimObject.GlobalStatus != ESimStatus.End && BDSimObject.GlobalStatus != ESimStatus.Initing)
            {
                flag = true;
            }
            return flag;
        }
        #endregion

        #region CmdRunSlower：仿真减速
        void CmdRunSlower_Excute(object o)
        {
            Scenario.RunSlower();
            //if (Scenario.stkPluginList != null)
            //{
            //    Scenario.stkPluginList[0].STKSlower();
            //}
            foreach (var item in Scenario.stkPluginList)
            {
                item.STKSlower();
            }
        }
        bool CmdRunSlower_CanExcute(object o)
        {
            bool flag = false;
            if (BDSimObject.GlobalStatus == ESimStatus.Run)
            {
                flag = true;
            }
            return flag;
        }
        #endregion

        #region CmdRunFaster：仿真加速
        void CmdRunFaster_Excute(object o)
        {
            Scenario.RunFaster();
            //if (Scenario.stkPluginList != null)
            //{
            //    Scenario.stkPluginList[0].STKFaster();
            //}
            foreach (var item in Scenario.stkPluginList)
            {
                item.STKFaster();
            }
        }

        bool CmdRunFaster_CanExcute(object o)
        {
            bool flag = false;
            if (BDSimObject.GlobalStatus == ESimStatus.Run)
            {
                flag = true;
            }
            return flag;
        }
        #endregion

        #endregion

        #region 帮助栏命令(执行事件)

        #region CmdBDSimHelp：打开BDSim本地帮助文档
        void CmdBDSimHelp_Excute(object o)
        {
            string FileName = Directory.GetCurrentDirectory() + "\\Resources\\Doc\\BDSim用户手册.pdf";
            if (File.Exists(FileName))
            {
                Process.Start(FileName);
            }
            else
            {
                MessageBox.Show("BDSim用户手册不存在");
            }
        }

        bool CmdBDSimHelp_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region CmdBDSimExperimentDoc：打开BDSim实验手册文档
        void CmdBDSimExperimentDoc_Excute(object o)
        {
            string FileName = Directory.GetCurrentDirectory() + "\\Resources\\Doc\\BDSim基础应用实验手册.pdf";
            if (File.Exists(FileName))
            {
                Process.Start(FileName);
            }
            else
            {
                MessageBox.Show("BDSim基础应用实验手册不存在");
            }
        }

        bool CmdBDSimExperimentDoc_CanExcute(object o)
        {
            bool flag = true;
            return flag;
        }
        #endregion

        #region CmdAboutUs：打开BDSim关于我们介绍
        void CmdAboutUs_Excute(object o)
        {

        }

        bool CmdAboutUs_CanExcute(object o)
        {
            bool flag = false;
            return flag;
        }
        #endregion

        #endregion

        #region 其他命令

        #region CmdResetScenario：重置仿真场景
        void CmdResetScenario_Excute(object o)
        {

        }

        bool CmdResetScenario_CanExcute(object o)
        {
            bool flag = false;
            return flag;
        }
        #endregion

        #region CmdAddExistModels：添加已有仿真模型
        void CmdAddExistModels_Excute(object o)
        {

        }

        bool CmdAddExistModels_CanExcute(object o)
        {
            bool flag = false;
            return flag;
        }
        #endregion

        #endregion

        #endregion

        #region 定义RoutedCommand（给常用命令定义快捷键）
        private RoutedCommand _SaveFile = new RoutedCommand();
        private RoutedCommand _OpenFile = new RoutedCommand();
        private RoutedCommand _DeleteModel = new RoutedCommand();
        private RoutedCommand _Init = new RoutedCommand();
        private RoutedCommand _Run = new RoutedCommand();

        public RoutedCommand RcmdSaveFile
        {
            get { return _SaveFile; }
            set { _SaveFile = value; }
        }
        
        public RoutedCommand RcmdOpenFile
        {
            get { return _OpenFile; }
            set { _OpenFile = value; }
        }
        
        public RoutedCommand DeleteModel
        {
            get { return _DeleteModel; }
            set { _DeleteModel = value; }
        }

        public RoutedCommand RcmdInit
        {
            get { return _Init; }
            set { _Init = value; }
        }

        public RoutedCommand RcmdRun
        {
            get { return _Run; }
            set { _Run = value; }
        }

        public void BindingRoutedCommand()
        {
            Parent.CommandBindings.Add(new CommandBinding(RcmdSaveFile,RcmdSaveFileExcute, RcmdSaveFileCanExcute));
            Parent.CommandBindings.Add(new CommandBinding(RcmdOpenFile, RcmdOpenFileExcute, RcmdOpenFileCanExcute));
            Parent.CommandBindings.Add(new CommandBinding(RcmdInit, RcmdInitExcute, RcmdInitCanExcute));
            Parent.CommandBindings.Add(new CommandBinding(RcmdRun, RcmdRunExcute, RcmdRunCanExcute));

            RcmdSaveFile.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control));
            RcmdOpenFile.InputGestures.Add(new KeyGesture(Key.O, ModifierKeys.Control));
            RcmdInit.InputGestures.Add(new KeyGesture(Key.F6));
            RcmdRun.InputGestures.Add(new KeyGesture(Key.F5));
        }


        private void RcmdSaveFileExcute(object sender, ExecutedRoutedEventArgs e)
        {
            CmdSaveFile_Excute(sender);
        }

        private void RcmdSaveFileCanExcute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = CmdSaveFile_CanExcute(sender);
        }

        private void RcmdOpenFileExcute(object sender, ExecutedRoutedEventArgs e)
        {
            CmdOpenFile_Excute(sender);
        }

        private void RcmdOpenFileCanExcute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = CmdOpenFile_CanExcute(sender);
        }

        private void RcmdInitExcute(object sender, ExecutedRoutedEventArgs e)
        {
            CmdInit_Excute(sender);
        }

        private void RcmdInitCanExcute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = CmdInit_CanExcute(sender);
        }

        private void RcmdRunExcute(object sender, ExecutedRoutedEventArgs e)
        {
            CmdRun_Excute(sender);
        }

        private void RcmdRunCanExcute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = CmdRun_CanExcute(sender);
        }

        #endregion

        #region MenuBar控件命令菜单绑定对象
        ObservableCollection<MenuCommand> _MenuBarItemList = new ObservableCollection<MenuCommand>();

        public ObservableCollection<MenuCommand> MenuBarItemList
        {
            get { return _MenuBarItemList; }
            set { _MenuBarItemList = value; }
        }

        void DefineMenuBarItem()
        {
            MenuBarItemList.Add(FileMenuDefine());
            MenuBarItemList.Add(ViewMenuDefine());
            MenuBarItemList.Add(DataToolMenuDefine());
            MenuBarItemList.Add(SettingMenuDefine());
            MenuBarItemList.Add(HelpMenuDefine());
        }

        MenuCommand FileMenuDefine()
        {
            MenuCommand FileMenu = new MenuCommand() { Header = "文件(F)"};
            FileMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "打开场景", ExcuteCommand = CmdOpenFile, Icon = new Image() { Style = (Style)Parent.FindResource("OpenFileImage") }, GestureKey ="Ctrl+O" });
            FileMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "保存", ExcuteCommand = CmdSaveFile, Icon = new Image() { Style = (Style)Parent.FindResource("SaveFileImage") }, GestureKey = "Ctrl+S" });
            //FileMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "插件管理", ExcuteCommand = CmdPluginManage, GestureKey = "S" });
            return FileMenu;
        }

        MenuCommand ViewMenuDefine()
        {
            MenuCommand ViewMenu = new MenuCommand() { Header = "视图(V)" };
            MenuCommand scenarioMenuCommand = new MenuCommand() { Header = "仿真场景",  ExcuteCommand = CmdScenarioConfig };
            
            ViewMenu.SubMenuCommandList.Add(scenarioMenuCommand);
            ViewMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "属性", ExcuteCommand = CmdPropertyConfig });
            ViewMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "系统消息",  ExcuteCommand = CmdSimMsgReport });
            ViewMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "三维可视化", ExcuteCommand = CmdThreeDimension });
            ViewMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "二维可视化",  ExcuteCommand = CmdEarthMap });
            ViewMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "定位评估", ExcuteCommand = CmdPPEvaluation });
            return ViewMenu;
        }

        MenuCommand DataToolMenuDefine()
        {
            MenuCommand DataToolMenu = new MenuCommand() { Header = "数据处理工具(T)" };
            DataToolMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "时间转换", ExcuteCommand = CmdTimeConvert });
            DataToolMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "坐标转换", ExcuteCommand = CmdCoordConvert });
            DataToolMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "导航电文解析", ExcuteCommand = CmdNavMsgDecode });
            DataToolMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "卫星定轨", ExcuteCommand = CmdROD });
            DataToolMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "实测数据定位", ExcuteCommand = CmdRealDataHandle });
            return DataToolMenu;
        }

        MenuCommand SettingMenuDefine()
        {
            MenuCommand SettingMenu = new MenuCommand() { Header = "设置(V)" };
            SettingMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "系统设置", ExcuteCommand = CmdSystemSetting });
            return SettingMenu;
        }

        MenuCommand HelpMenuDefine()
        {
            MenuCommand HelpMenu = new MenuCommand() { Header = "帮助(H)" };
            HelpMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "用户手册", ExcuteCommand = CmdBDSimHelp });
            HelpMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "基础应用实验手册", ExcuteCommand = CmdBDSimExperimentDoc });
            HelpMenu.SubMenuCommandList.Add(new MenuCommand() { Header = "关于我们", ExcuteCommand = CmdAboutUs });

            return HelpMenu;
        }

        #endregion

        #region 为STK启动存储卫星及地面站位置

        private void SaveSatPV()
        {
            File.WriteAllText(Scenario.stkPluginList[0].OrbitFile, BDSimObject.GlobalStartTime.JD.ToString() + "\n");
            foreach (var sat in (Scenario.SegmentColletion[0] as SpaceSegment).AllSatellite)
            {
                   string orbPV = string.Format("{0} {1} {2} {3} {4} {5} {6} {7}\n",sat.Id, sat.Name, sat.Orbit.InitPV_ECI.X, sat.Orbit.InitPV_ECI.Y, sat.Orbit.InitPV_ECI.Z, sat.Orbit.InitPV_ECI.VX, sat.Orbit.InitPV_ECI.VY, sat.Orbit.InitPV_ECI.VZ);
                   File.AppendAllText(Scenario.stkPluginList[0].OrbitFile, orbPV);
            }
        }

        private void SaveStation()
        {
            File.WriteAllText(Scenario.stkPluginList[0].InitStasFile, BDSimObject.GlobalStartTime.JD.ToString() + "\n");
            foreach (var sub in (Scenario.SegmentColletion[2] as GroundSegment).SubGroundSegmentList)
            {
                foreach (var sta in sub.GroundList)
                {
                    foreach (var item in sta.StationList)
                    {
                        string staData = string.Format("{0} {1} {2} {3} {4} {5}\r\n", item.Id, item.Type, item.Pos_BLH.B, item.Pos_BLH.L, item.Pos_BLH.H, item.Name);
                        File.AppendAllText(Scenario.stkPluginList[0].InitStasFile, staData);
                    }
                }
            }
        }

        #endregion
    }
}
